<template>
    <div class="test">
        <h2>{{ msg }}</h2>
        <h2>学生姓名:{{name}}</h2>
        <h2>学生年龄:{{age}}</h2>
        <button @click="sendStudentName">把学生名传给School组件</button>
    </div>
</template>

<script>
    export default {
        name:'Student',
        data() {
            return {
                msg:'个人信息',
                name:'trent',
                age:18
            }
        },
        methods:{
            sendStudentName(){
                //触发x上的hello事件
                this.$bus.$emit('hello',this.name)
            }
        }
    }
</script>

<style scoped>
    .test{
        background-color: pink;
        padding: 5px;
        margin-top: 30px;
    }
</style>